<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  let name = 'wzy';

  let grade = [
    {name: 'js', score: 99},
    {name: 'docker', score: 99},
  ]

  function average(grade) {
    let total = grade.reduce((a, b) => {
      return (a + b.score)
    }, 0)
    return `你的平均分是：${total / grade.length}`
  }

  console.log(average(grade));

  let user = {
    name: 'wzy',
    grade: [
      {name: 'js', score: 99},
      {name: 'docker', score: 99},
    ],
    average() {
      let total = this.grade.reduce((a, b) => {
        return (a + b.score)
      }, 0)
      return `${this.name}平均分是：${total / grade.length}`
    }
  }
  console.log(user.average());
</script>
</body>
</html>